<div class="cbac">

  <h2>Subset:</h2>
  <form action="<%= request.url %>" method="get" name="subset_view_form">
    <b>Privilege set</b> starts with: <input type="text" name="priv_substr" value="<%= params[:priv_substr] %>" /><br />
    <b>Role</b> starts with: <input type="text" name="role_substr" value="<%= params[:role_substr] %>" /><br/>
    <input type="submit" value="Submit" />
  </form>

  <h1>Permissions</h1>
  <table>
    <tr>
      <th>Privilegeset</th>
      <% (@context_roles.sort { |x, y| x[0].to_s <=> y[0].to_s }).each do |name, comment| %>
        <th><%= name %></th>
      <% end %>
      <% (@generic_roles.sort { |x, y| x.name <=> y.name }).each do |role| %>
        <th><%= role.name %></th>
      <% end %>
    </tr>
    <% (@sets.sort do |x,y| x[0].to_s <=> y[0].to_s end).each do |token, set| %>
      <tr>
        <td><span title ="<%= set.comment %>"><%= set.name %></span></td>
        <% (@context_roles.sort { |x, y| x[0].to_s <=> y[0].to_s }).each do |context_role, comment| %>
          <td class="checked">
            <%= render :partial => "cbac/permissions/update_context_role.html", :locals => {:context_role => context_role.to_s,
              :set_id => set.id.to_s, :update_partial => false} %>
          </td>
        <% end %>
        <% (@generic_roles.sort { |x, y| x.name <=> y.name }).each do |role| %>
          <td class="checked">
            <%= render :partial => "cbac/permissions/update_generic_role.html", :locals => {:role => role,
              :set_id => set.id.to_s, :update_partial => false} %>
          </td>
        <% end %>
      </tr>
    <% end %>
  </table>
</div>
